# Copyright 2009 http://www.yuntien.com
# Licensed under the Apache License, Version 2.0

from ytblog.controller.common import *
    
class BlogPromoteController(BlogController):
  @check_blog_id
  @authorize(Blog, authorization.OPERATION_PROMOTE)
  def post(self, id):
    blog = Blog.get_by_str_id(id)
    
    if users.is_current_user_admin():
      blog.points = blog.points + ytblog.config.HOMEPAGE_POINTS
    else:
      blog.points = blog.points + 1
      
    if blog.points >= ytblog.config.HOMEPAGE_POINTS:
      blog.popular = True
      
    blog.put()

    #just refresh current page
    self.redirect(self.request.referer)
